<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script>
    function Person(name) {
        this.name = name;
        this.runTest1=function () {
            console.info(this.name);
        }
        //动态添加原型方法
        if(typeof this.test2 != 'function'){
            Person.prototype.test2 = function () {
                console.info("run test2");
            }
        }
    };
    Person.prototype.age = "19";
    Person.prototype.say = function () {
        alert(111);
    };
    var p = new Person("张三");
    console.info(p.age);
    p.say()
    p.runTest1()


    p.test2();
</script>
<body>

</body>
</html>